CC = gcc
CFLAGS = -Wall -O3 -g -Wincompatible-pointer-types -MMD -MP
LDFLAGS = 

# 目录设置
SRC_DIR = src_v2
BUILD_DIR = build_v2
SOURCES = $(wildcard $(SRC_DIR)/*.c)
OBJECTS = $(patsubst $(SRC_DIR)/%.c,$(BUILD_DIR)/%.o,$(SOURCES))
DEPFILES = $(OBJECTS:.o=.d)

# 输出可执行文件
EXECUTABLE = cube

# 默认规则
all: $(EXECUTABLE)

# 包含自动生成的依赖文件
-include $(DEPFILES)

# 创建build目录并编译
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.c | $(BUILD_DIR)
	$(CC) $(CFLAGS) -c $< -o $@

# 创建build目录规则
$(BUILD_DIR):
	mkdir -p $@

# 链接可执行文件
$(EXECUTABLE): $(OBJECTS)
	$(CC) $(LDFLAGS) $^ -o $@

# 清理规则
clean:
	rm -rf $(BUILD_DIR) $(EXECUTABLE)

.PHONY: all clean cov